package views.screens.nightScreens;

import java.awt.Component;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import views.MafiaFrame;
import views.panes.ButtonUser;
import views.panes.ButtonUserNoSound;
import views.panes.ButtonUserNoVote;
import views.screens.Screen;

class nightScreen4 extends JPanel implements Screen{

    int nrRows, nrCols;
    MafiaFrame mafiaFrame;
    nightScreen1 ns1;
    String action1, action2;

    public nightScreen4(final MafiaFrame mf, final String action1, final String action2, final String action3, final nightScreen1 ns1) {
        super(new GridLayout(5,2));
        this.mafiaFrame = mf;
        this.ns1 = ns1;
        this.action1 = action1;
        this.action2 = action2;

        add(new JLabel("You have chosen:"));
        add(new Component() {
            });

        add(new JLabel("Yourself: "));
        add(new ButtonUser(action1, this));
        add(new JLabel("Target: "));
        add(new ButtonUser(action2, this));

        add(new JLabel("Action type: "));
        if(action3.equals("No_vote")){
            add(new ButtonUserNoVote(this));
        }else{
            add(new ButtonUserNoSound(this));
        }

        JPanel jp2 = new JPanel();
        JButton ok = new JButton("OK");

        jp2.add(ok);
        add(jp2);

        ok.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                boolean b = mf.addAction(action1, action2, action3);
                mf.update(new nightScreen5(b, action2, mf, ns1));
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });

        JPanel jp = new JPanel();
        JButton cancel = new JButton("Cancel");

        jp.add(cancel);
        add(jp);

        cancel.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                mf.update(new nightScreen3(mf, action1, action2, ns1));
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });
    }

    @Override
    public void setAction(String action) {
        //do nothing
    }

}
